package org.xiaov.lunasql.engine.function;

import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr;

/**
 * <p>
 * IfNull2NvlFunc
 * </p>
 *
 * @author LunaSQL
 * @since 2024/12/15 22:18
 */
public class IfNull2NvlFunc implements MySqlFunction {
    private final static String METHOD_NAME = "ifnull";
    private final static String TARGET_METHOD_NAME = "nvl";

    @Override
    public boolean accept(SQLMethodInvokeExpr methodInvokeExpr) {
        return METHOD_NAME.equalsIgnoreCase(methodInvokeExpr.getMethodName());
    }

    @Override
    public void transform(SQLMethodInvokeExpr methodInvokeExpr) {
        methodInvokeExpr.setMethodName(TARGET_METHOD_NAME);
    }
}
